import java.io.File;
import java.util.Iterator;

import org.dom4j.Document;
import org.dom4j.Element;
import org.dom4j.io.SAXReader;


public class readXml {

	/**
	 * @param args
	 */
	@SuppressWarnings("unchecked")
	public static void main(String[] args) {
		@SuppressWarnings("unused")
		long lasting = System.currentTimeMillis();   
		  try {   
		   File f = new File("text.xml");   
		   SAXReader reader = new SAXReader();   
		   Document doc = reader.read(f);   
		   Element root = doc.getRootElement();   
		   Element foo;   
		   for (Iterator i = root.elementIterator("employee1"); i.hasNext();) {   
		    foo = (Element) i.next();
		    System.out.println("姓名:" + foo.elementText("name"));
		    System.out.println("性别:" + foo.elementText("sex"));
		    System.out.println("年龄:" + foo.elementText("age"));  
		    System.out.println("生日:" + foo.elementText("birthday"));
		   }   
		  } catch (Exception e) {   
		   e.printStackTrace();   
		  }   


	}

}
